<%@page import="org.ilead.iserve.model.User"%>
<%@page import="org.ilead.iserve.constants.SessionKeyConstant"%>
<%@page import="java.util.Map"%>
<%@page import="org.ilead.iserve.service.manager.UserManager"%>
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	Map<String,String[]> paramMap = request.getParameterMap();
	boolean isInvalid = false;
	if(paramMap.containsKey("loginName")){
		String username = request.getParameter("loginName");
		isInvalid = UserManager.getInstance().hasNameRegister(username);
	}else if(paramMap.containsKey("email")){
		String email = request.getParameter("email");
		isInvalid = UserManager.getInstance().hasEmailRegister(email);
	}else if(paramMap.containsKey("password")){
		String password = request.getParameter("password");
		User user = (User)request.getSession().getAttribute(SessionKeyConstant.LOGIN_USER);
		isInvalid = !user.getPassword().equals(password);
	}
	if(isInvalid == true) {
		//AJAX
		response.setContentType("text/xml");
		response.setHeader("Cache-Control","no-stroe");
		response.setHeader("pragma","no-cache");
		response.setDateHeader("Expries",0);
		response.getWriter().write("<msg>invalid</msg>");
	}else{
		//AJAX
		response.setContentType("text/xml");
		response.setHeader("Cache-Control","no-stroe");
		response.setHeader("pragma","no-cache");
		response.setDateHeader("Expries",0);
		response.getWriter().write("<msg>validate</msg>");
	}
%>
